<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 1.实例化xhr对象
    var xhr = new XMLHttpRequest()
    // 2.构建请求地址
    // 两个参数 1->请求方式 get   2->请求 http://localhost:3000/ajax
    xhr.open("get", "http://localhost:3000/ajax")
    // 3.发送请求
    xhr.send()
    // 4.接收响应数据
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            console.log(xhr.responseText)
        }
    }
</script>
</html>